<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组方法</title>
</head>

<body>

</body>
<script>
    let arr = [1, 2, 3]
    console.log(arr.unshift(0), arr);
    console.log(arr.push(4, 5), arr);
    console.log(arr.shift(), arr);
    console.log(arr.pop(), arr);// [1, 2, 3, 4]

    console.log(arr.slice(0, 3), arr);// 返回被截取的元素，不会改变原数组
    // console.log(arr.splice(0), arr);// 返回被删除的元素，会改变原数组
    // console.log(arr.splice(0, 1), arr);// 返回被删除的元素，会改变原数组
    console.log(arr.splice(0, 1, 22, 33, 44, 55), arr);// 返回被删除的元素，会改变原数组[22, 33, 44, 55, 2, 3, 4]
</script>

</html>